fn main() {
    //print_bytes_of_interger();

    unsafe {
        PROCESS[0] = Some(LDT { ldt_sel: 12, ldt: [0; 8] });
        let p = PROCESS[0].as_mut();
        match p {
            Some(ldt) => {
                //println!("{}", ldt.ldt_sel);
                println!("{}", ldt.ldt.as_ptr() as  u32);
                ldt.ldt[0] = 123;
            },
            _ => {},
        };

        let pp = PROCESS[0].as_mut();
        println!("{}", pp.unwrap().ldt.as_ptr() as u32);
        //println!("{}", *ptr_ldt.offset(0));
    }

    unsafe {
        match PROCESS[0].as_mut() {
            Some(ldt) => {
                //println!("{}", ldt.ldt_sel);
                println!("{}", ldt.ldt.as_ptr() as  u32);
                ldt.ldt[0] = 123;
            },
            _ => {},
        };
    }

    
}

#[repr(C)]
struct LDT {
    ldt_sel : u16,
    ldt : [u32; 8],
}

static mut PROCESS:[Option<LDT>;1] = [None];

/*
fn print_bytes_of_interger() {
    println!("======== print integer variable size, min, max=============");
    println!("u8 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2u8), u8::min_value(), u8::max_value());
    println!("i8 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2i8), i8::min_value(), i8::max_value());
    println!("u16 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2u16), u16::min_value(), u16::max_value());
    println!("i16 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2i16), i16::min_value(), i16::max_value());
    println!("u32 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2u32), u32::min_value(), u32::max_value());
    println!("i32 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2i32), i32::min_value(), i32::max_value());
    println!("u64 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2u64), u64::min_value(), u64::max_value());
    println!("i64 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2i64), i64::min_value(), i64::max_value());
    println!("u128 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2u128), u128::min_value(), u128::max_value());
    println!("i128 size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2i128), i128::min_value(), i128::max_value());
    println!("usize size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2usize), usize::min_value(), usize::max_value());
    println!("isize size: {} bytes, min: {}, max: {}", std::mem::size_of_val(&2isize), isize::min_value(), isize::max_value());
}
*/